<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2024/11/15
  Time: 12:56
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>Title</title>
</head>
<style>
    table{
        margin: auto;
    }
    div{
        width: 600px;
        margin: auto;
    }

    #bookId{
        width: 23px;
    }
</style>
<body>
    <form action="bookDelete" method="post" id="form1">
        <table border="1px">
            <tr>
                <td>书本ID</td>
                <td>书本名字</td>
                <td>书本作者</td>
                <td>书本类型</td>
                <td>出版时间</td>
                <td>操作</td>
                <td>操作</td>
<%--                <td>操作</td>--%>
            </tr>
            <c:forEach items="${bookList}" var="b">
                <tr>
                    <td>${b.bookId}</td>
                    <td>${b.bookName}</td>
                    <td>${b.bookWriter}</td>
                    <td>${b.bookType}</td>
                    <td><fmt:formatDate value="${b.putDate}"></fmt:formatDate></td>
                    <td>
                        <input type="button" value="查看" onclick="show('${b.bookId}','${b.bookName}','${b.bookWriter}','${b.bookType}','${b.putDate}')">
                    </td>
                    <td>
                        <a href=bookDelete?bookId=${b.bookId}>删除</a>
                    </td>
<%--                    <td>--%>
<%--                        <a href="bookUpdate?bookId=${b.bookId}&bookName=${b.bookName}&bookWriter=${b.bookWriter}&bookType=${b.bookType}">修改</a>--%>
<%--                    </td>--%>
                </tr>
            </c:forEach>
        </table>

            <div>
                id:   <input type="text"  id="bookId" name="bookId" value="0" readonly>
                书本名字: <input type="text" id="bookName" name="bookName" value="">
                书本作者: <input type="text" id="bookWriter" name="bookWriter" value=""><br>
                书本类型: <input type="text" id="bookType" name="bookType" value="">
                出版时间: <input type="text" id="putDate" name="putDate" value="">
                <br>
                <input type="button" value="查询" onclick="infoHarf('listBook')" >
                <input type="button" value="修改" onclick="infoHarf('bookUpdate')" >
                <input type="button" value="删除" onclick="infoHarf('bookDelete')" >
                <input type="button" value="清除" onclick="show(0,'','','','')" >
            </div>

        <div>
            <c:if test="${currentPage > 1}">
                <a href="listBook?page=${currentPage - 1}&pageSize=${pageSize}">上一页</a>
            </c:if>

            <c:forEach items="${pageNumbers}" var="pageNumber">
                <c:if test="${pageNumber != currentPage}">
                    <a href="listBook?page=${pageNumber}&pageSize=${pageSize}">${pageNumber}</a>
                </c:if>
            </c:forEach>

            <c:if test="${currentPage < pageCount}">
                <a href="listBook?page=${currentPage + 1}&pageSize=${pageSize}">下一页</a>
            </c:if>
        </div>

    </form>
</body>
<script>
    function $(id){
        return document.getElementById(id);
    }
    function mysubmit(o){
        //var val=o.parentNode.parentNode.firstElementChild.innerHTML;
        $("id").value=o;
        $("form1").submit();
    }
    function check(){
        var name=document.getElementById('all');
        name.checked;
        var allName=document.getElementsByName("deleteAll");
        for(var i=0;i<allName.length;i++){
            allName[i].checked=name.checked;
        }
    }
    function show(a,b,c,d,e){
        $("bookId").value=a;
        $("bookName").value=b;
        $("bookWriter").value=c;
        $("bookType").value=d;
        $("putDate").value=e;
    }
    function infoHarf(url){
        $("form1").action=url;
        $("form1").submit();
    }
</script>

</html>
